import {Injectable, Injector} from '@angular/core';
import {ServicesModule} from './services.module';
import {BaseService} from './base/base.service';
import {User} from '../entity/admin';
import {map} from 'rxjs/operators';
import {Menu} from '../entity/Menu';
import {Observable} from 'rxjs';

@Injectable({
  providedIn: ServicesModule
})
export class HomeService extends BaseService {

  constructor(public injector: Injector) {
    super(injector);
  }

  userInfo(): Observable<User> {
    return this.httpServer.get(this.uri + 'admin/userInfo').pipe(
      map(
        (res: { data: User }) => res.data
      )
    );
  }

  listMenu(): Observable<Menu[]> {
    return this.httpServer.get(this.uri + 'menu/listMenu').pipe(
      map(
        (res: { data: Menu[] }) => res.data
      )
    );
  }
}
